<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:s="http://jboss.com/products/seam/taglib"
	  xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:ui="http://java.sun.com/jsf/facelets">
	
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
			<div align="center">	
				<rich:panel style="width:450px;" id="majU" headerClass="rich-panel-header-adm" bodyClass="rich-panel-body-acc">
				<f:facet name="header">
						<h:outputText value="Ajout d'une rubrique" />
					</f:facet>
				<s:fragment rendered="#{empty gestionContenu.rubriquesDroitAjout()}">
				<h:outputText value="Vous n'avez pas les droits nécessaire pour ajouter une rubrique" />
				</s:fragment>
				<s:fragment rendered="#{not empty gestionContenu.rubriquesDroitAjout()}">
				<h:messages globalOnly="true" styleClass="erreur"/>
						
						<h:form>
					<h:panelGrid columns="2" columnClasses="top,top">
            <rich:fileUpload fileUploadListener="#{fileUploadBean.listenerLogo}"
                			maxFilesQuantity="#{fileUploadBean.uploadsAvailableLogo}"
                			uploadData="#{file.data}"
                			id="upload"
                			addControlLabel="Ajouter un fichier..." 
                			clearAllControlLabel="Supprimer Tout" 
                			clearControlLabel="Supprimer"
							stopEntryControlLabel="Arêter" 
							uploadControlLabel="Joindre"
							immediateUpload="#{fileUploadBean.autoUpload}"
                			acceptedTypes="jpg, gif, png, bmp"
                			noDuplicate="true"
                			allowFlash="true"
                			listHeight="50"  
                       		listWidth="200"  
                     		style="height:100;">
                <a4j:support event="onuploadcomplete" reRender="info" />
                
                
            </rich:fileUpload>
            <h:panelGroup id="info">
                <rich:panel bodyClass="info">
                    <f:facet name="header">
                        <h:outputText value="Information du logo joint" />
                    </f:facet>
                   
                    <h:outputText value="Aucun Fichier Joint"
                        rendered="#{fileUploadBean.logo.data==null}" />
                    
                                <a4j:mediaOutput element="img" mimeType="#{fileUploadBean.logo.mime}"
                                    createContent="#{fileUploadBean.paintUploadLogo}" value="fileUploadBean.logo"
                                    style="width:100px; height:100px;" cacheable="false"
                                    rendered="#{fileUploadBean.logo.data!=null}">
                                    <f:param value="#{fileUploadBean.timeStamp}" name="time"/>  
                                </a4j:mediaOutput>
                   
                </rich:panel>
                
                <rich:spacer height="3"/>
                <br />
                <a4j:commandButton styleClass="button" action="#{fileUploadBean.clearUploadData}"
                    reRender="info, upload" value="Clear Uploaded Data"
                    rendered="#{fileUploadBean.logo.data!=null or fileUploadBean.uploadsAvailableLogo==0}" />
            </h:panelGroup>
        </h:panelGrid>
        </h:form>
						
					   <h:form id="ajoutRubrique" ajaxSubmit="true" reRender="titre,niveauacces,parent">
					       <s:validateAll>
					       	<h:panelGrid columns="3">
					           <h:outputText value="Titre" />
					           <h:inputText id="titre" value="#{rubrique.titreContenu}" required="true"/>
					           <rich:message errorClass="erreur" for="titre"/>
					        
					           <h:outputText value="Niveau d'accès" />
					           <h:selectOneMenu value="#{rubrique.niveauAcces}" required="true">
					  				<s:selectItems id="niveauacces"
					  								value="#{enum.getListNiveauAcces()}" 
					  								var="niveauAcces" 
					  								label="#{niveauAcces.label}"/>
					  				<s:convertEnum />
								</h:selectOneMenu>
								<rich:message errorClass="erreur" for="niveauacces"/>
					         
					           <h:outputText value="Rubrique Parent" required="true"/>
					           <h:selectOneMenu value="#{rubrique.parent}" >
					  			<s:selectItems 	id="parent"
					  							value="#{gestionContenu.rubriquesDroitAjout()}" 
					  							var="ctn" 
					  							label="#{ctn.titreContenu}"
					  							/>
					  							<f:converter converterId="rubriqueConverter"/>		
								</h:selectOneMenu>
								<rich:message errorClass="erreur" for="parent"/>
								
								
								<h:outputText value="Lien Web" />
					           	<h:inputText id="web" value="#{rubrique.lienWeb}"/>
					           	<h:message  for="web"/>
					         </h:panelGrid>
					       </s:validateAll>
					     
					     
					     <h:commandButton type="submit" class="button" value="valider" action="#{gestionContenu.addContenu(rubrique)}"/>
					     <s:button value="retour"  styleClass="button" action="#{menu.afficheGestionRubrique()}"/>
					   </h:form>
					   <h:form>
					  
					</h:form>
					</s:fragment>
				 </rich:panel>
			</div>
</ui:composition>